using UnityEngine;
using System.Collections;

public class UpdateMes : Message
{
	public int unit;
	public Vector3 pos;
	public UpdateMes(string buffer, UnitSpawner spawner)
	{
		messageBuffer = buffer;
		unPack(spawner);
	}
	public void unPack (UnitSpawner spawner)
	{
		//U#XPOS#YPOS#
		string[] mes = messageBuffer.Split('#');
		for(int i=0;i<mes.Length/3;++i)
		{
			unit = int.Parse(mes[i]);
			pos.x = float.Parse(mes[i+1]);
			pos.y = float.Parse(mes[i+2]);
			spawner.UpdateUnit(unit, pos);
		}
	}
}